﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Manager.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
<%@ Import Namespace="B2B.Models" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">

<h2>QuotesSentPostBuy</h2>

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="HEAD" runat="server">
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="main_content" runat="server">
        <%
            ArrayList ds_QuotesSentPostBuy = (ArrayList)ViewData["ds_QuotesSent_SPM"];
         int i = 0; int k = 0;
     %>
    <h6> Management -> Quotes Sent Post Buy</h6>
    <table id="deleteQuote">
        <tr style="background-color:#177f75; font-size:17px;color:	#a6fdbf">
            <th style="padding:5px; width:300px">Product</th>
            <th style="padding:5px; width:100px">File</th>            
            <th style="padding:5px; width:250px">Reciver</th>
            <th style="padding:5px; width:100px">Tình Trạng</th>
            <th></th>
            <th></th>
        </tr>
        <% foreach (var quote in ds_QuotesSentPostBuy)
           {
               string maBG = ((SP_QuoteSent)quote).MaBaoGia.ToString();
               string tenSP = ((SP_QuoteSent)quote).TenSP.ToString();
               string fileName = ((SP_QuoteSent)quote).File.ToString();
             //  string link = ((SP_QuoteSent)quote).Link.ToString();
               string reciver = ((SP_QuoteSent)quote).EmailNguoiNhan.ToString();
               int tinhTrang = ((SP_QuoteSent)quote).TinhTrang;
               string chuoiTinhTrang = "";
              
               switch (tinhTrang)
               {
                   case 1: chuoiTinhTrang = "Reject"; break;
                   case 2: chuoiTinhTrang = "Accept"; break;
                   default: chuoiTinhTrang = "Waiting"; break;
               }         
               if(i % 2 ==0)
               {
        %>
             <tr id="tr<%=k %>" style="background-color:#d1bff0; font-size:14px">
                <td><a style="color:black" href="#"> <%=tenSP %></a></td>
                <td align="center"><a style="padding:5px; color:black" href="/Files/Download?file=<%=fileName %>"><%=fileName %></a> </td>
                <td style="padding:5px; color:black" align="center"><%=reciver %></td>
                <td style="padding:5px; color:black" align="center"><%=chuoiTinhTrang %></td>                
                <td>
                    <%if(tinhTrang == 1){ %>
                    <input type="button" onclick="deleteQuote(<%=maBG %>,'<%=k %>    ')" value="Delete" />
                    <%} %>

                </td>
            </tr>
        <%} 
          else
          {                     
        %>
            <tr id="tr1" style="font-size:14px">
                <td><a  href="#"> <%=tenSP %></a></td>
                <td style="padding:5px;" align="center"><a href="/Files/Download?file=<%=fileName %>"><%=fileName %></a> </td>
                <td style="padding:5px;" align="center"><%=reciver %></td>
                <td style="padding:5px;" align="center"><%=chuoiTinhTrang %></td>             
                <td style="padding:5px;">
                    <%if(tinhTrang == 1){ %>
                    <input type="button" onclick="deleteQuote(<%=maBG %>,'<%=k %>    ')" value="Delete" />
                    <%} %>
                </td>
            </tr>
        <%}%>
        <%i++; k++;
           } %>
    </table>

    <div id="trigger-list">
        <% 
            int tongtrangGui = int.Parse(ViewData["tongtrang_guiSPM"].ToString());
            for(int j = 0; j < tongtrangGui; j++)
            {
        %>
            <a class="trigger error-trigger" href="/Manage/QuotesSentPostBuy/<%=j %>"><%=j+1 %></a>
        <%
        }
        %>
    </div>

    <script type="text/ecmascript">
        function deleteQuote(mabg, tr) {
            $.getJSON("/Manage/DeleteQuote?maBaoGia=" + mabg,
                function (data) {
                    if (data == 1) {
                        $("#deleteQuote tr#tr" + tr).remove();
                    }else{
                        alert("You can't delete this quote product");
                    }
                });
        }
    </script>
</asp:Content>
